package com.huangliusong.desigin.pattern.creational.singleton;

/**
 * 懒汉
 * @author huangliusong
 * @since 2018/10/10
 * {@link }
 */
public class LazySingleton {
    private static LazySingleton lazySingleton=null;

    private LazySingleton() {
        if (lazySingleton!=null){
            throw new RuntimeException("单li构造器禁止进行反射");
        }

    }

    public synchronized static LazySingleton getInstance(){
        if ( lazySingleton==null){
            lazySingleton=new LazySingleton();
        }
        return lazySingleton;
    }
}
